package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.result.ResultInfo;
import com.ruoyi.system.domain.TInandout;
import com.ruoyi.system.service.ITInandoutService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Xiexingxie
 * @date 2022/12/12 上午 09:54
 */

@RestController
@RequestMapping("/system/inandout")
public class TInandoutController extends BaseController {
    
    // 引入Sl4j日志
    private final static Logger log = LoggerFactory.getLogger(TInandoutController.class);
    
    @Autowired
    private ITInandoutService itInandoutService;

    @PreAuthorize("@ss.hasPermi('system:inandout:list')")
    @GetMapping("/getinandoutInfo")
    public TableDataInfo selectInandoutAllinfo(TInandout tInandout){
        startPage();
        List<TInandout> tInandouts = itInandoutService.selectAllInandoutInfo(tInandout);
        return getDataTable(tInandouts);
    }

    /**
     * 获取车位销售详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:inandout:query')")
    @GetMapping(value = "/{iid}")
    public AjaxResult getInfo(@PathVariable("iid") Integer iid)
    {
        log.debug("根据IID：{},查询信息", iid);
        return success(itInandoutService.selectTCarportById(iid));
    }

    /**
     * 新增车位销售
     */
    @PreAuthorize("@ss.hasPermi('system:inandout:add')")
    @Log(title = "车位销售", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInandout tInandout)
    {
        log.debug("新增的信息为：{}",tInandout);
        return toAjax(itInandoutService.insertTinandout(tInandout));
    }

    /**
     * 修改车位销售
     */
    @PreAuthorize("@ss.hasPermi('system:inandout:edit')")
    @Log(title = "车位销售", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInandout tInandout)
    {
        log.debug("修改的信息为：",tInandout);
        return toAjax(itInandoutService.updateTinandout(tInandout));
    }

    /**
     * 删除车位销售
     */
    @PreAuthorize("@ss.hasPermi('system:inandout:remove')")
    @Log(title = "车位销售", businessType = BusinessType.DELETE)
    @DeleteMapping("/{iids}")
    public AjaxResult remove(@PathVariable Integer[] iids)
    {
        log.debug("删除的IID为：{}",iids);
        return toAjax(itInandoutService.deleteTinandoutByIids(iids));
    }
    
    @PostMapping("/addinsplatenumber")
    public AjaxResult insertInsPlatenumber(@RequestBody TInandout inandout){
        return toAjax(itInandoutService.insertInsPlatenumber(inandout));
    }
    
}
